import json


class TaxonomyUtil:

    def __init__(self):
        self.json_data = None
        self.load_file()

    def load_file(self):
        with open('../data/chest_graph_2021_07_15.json', 'r', encoding='UTF-8') as f:
            self.json_data = json.load(f)

    def get_deep_taxonomy(self):
        def find_next(cur, tag):
            if len(cur['children']) > 0:
                children = cur['children']
                for child in children:
                    find_next(child,
                              (tag + child['name']) if tag == '' else (tag + '-' + child['name']))
            else:
                print(tag)

        find_next(self.json_data, '')


if __name__ == '__main__':
    app = TaxonomyUtil()
    app.get_deep_taxonomy()
